package com.ruoyi.project.oms.service;

import java.time.LocalDateTime;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.db.oms.mapper.OmsOrderMapper;
import com.ruoyi.db.oms.domain.OmsOrder;
import com.ruoyi.db.oms.domain.query.OmsOrderQueryVo;

/**
 * 订单列表Service业务层处理
 *
 * @author yfy
 * @date 2020-04-27
 */
@Service
public class OmsOrderService
{
    @Autowired
    private OmsOrderMapper omsOrderMapper;

    /**
     * 订单超时处理
     *
     * @return 结果
     */
    public int omsOrderUpdateAuto(OmsOrder omsOrder)
    {
        omsOrder.setEndTime(LocalDateTime.now());
        omsOrder.setAddTime(LocalDateTime.now().minusHours(2));

        return omsOrderMapper.omsOrderUpdateAuto(omsOrder);
    }

    /**
     * 查询订单列表
     *
     * @param id 订单列表ID
     * @return 订单列表
     */
    public OmsOrder selectOmsOrderById(Long id)
    {
        return omsOrderMapper.selectOmsOrderById(id);
    }

    /**
     * 查询订单列表列表
     *
     * @param omsOrderQueryVo 订单列表查询参数
     * @return 订单列表
     */
    public List<OmsOrder> selectOmsOrderList(OmsOrderQueryVo omsOrderQueryVo)
    {
        return omsOrderMapper.selectOmsOrderList(omsOrderQueryVo);
    }

    /**
     * 新增订单列表
     *
     * @param omsOrder 订单列表
     * @return 结果
     */
    public int insertOmsOrder(OmsOrder omsOrder)
    {
        return omsOrderMapper.insertOmsOrder(omsOrder);
    }

    /**
     * 修改订单列表
     *
     * @param omsOrder 订单列表
     * @return 结果
     */
    public int updateOmsOrder(OmsOrder omsOrder)
    {
        omsOrder.setUpdateTime(LocalDateTime.now());
        return omsOrderMapper.updateOmsOrder(omsOrder);
    }

    /**
     * 批量删除订单列表
     *
     * @param ids 需要删除的订单列表ID
     * @return 结果
     */
    public int deleteOmsOrderByIds(Long[] ids)
    {
        return omsOrderMapper.deleteOmsOrderByIds(ids);
    }

    /**
     * 删除订单列表信息
     *
     * @param id 订单列表ID
     * @return 结果
     */
    public int deleteOmsOrderById(Long id)
    {
        return omsOrderMapper.deleteOmsOrderById(id);
    }
}
